﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using FlyingClub.Models;

namespace FlyingClub.Controllers
{
    public class HomeController : BeforeController
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            if (Session["ID"] != null)
            {
                ViewBag.Firstname = Session["Firstname"];
                ViewBag.Lastname = Session["Lastname"];
            }
            return View();
        }

        public ViewResult AccessError()
        {
            return View();
        }

        public ViewResult AboutUs()
        {
            return View();
        }

        public ViewResult Contact()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Contact(Contact contact)
        {
            if (ReceiveEmail(contact.Name, contact.Email, contact.Subject, contact.Content))
                ViewBag.Confirmation = "Votre message a bien été envoyé !";
            else
                ViewBag.Confirmation = "Echec lors de l'envoi de votre message. Vous pouvez nous contacter à cette adresse en utilisant votre messagerie : flyingclubproject@gmail.com.";

            return View();
        }
    }
}
